package com.jt.safe.ui.adpter

import android.view.LayoutInflater
import android.view.ViewGroup
import android.widget.ImageView
import com.bumptech.glide.Glide
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.BaseViewHolder
import com.jt.safe.R

class ParentVideoAdapter : BaseQuickAdapter<String, BaseViewHolder>(null) {
    override fun convert(helper: BaseViewHolder, item: String?) {
        val image = helper.getView<ImageView>(R.id.image)
        Glide.with(mContext)
            .load("https://p9.pstatp.com/large/4c87000639ab0f21c285.jpeg")
            .placeholder(android.R.color.white)
            .into(image)
    }

    override fun getItemViewType(position: Int): Int {
        return if (position % 2 == 1) {
            0
        } else {
            1
        }
    }

    override fun onCreateDefViewHolder(parent: ViewGroup?, viewType: Int): BaseViewHolder {
        if (viewType == 0) {
            return BaseViewHolder(LayoutInflater.from(mContext).inflate(R.layout.parent_video_item1, parent, false));
        } else {
            return BaseViewHolder(LayoutInflater.from(mContext).inflate(R.layout.parent_video_item2, parent, false));
        }
    }
}